package com.itheima.controller.cms;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.core.PageInfo;
import com.itheima.core.R;
import com.itheima.pojo.cms.CmsSubject;
import com.itheima.service.cms.CmsSubjecService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/subject")
public class CmsSubjectController {

    @DubboReference
    private CmsSubjecService cmsSubjecService;



    /*根据专题名称分页获取商品专题*/

    @GetMapping("list")
    public R list(  String keyword,  @RequestParam(defaultValue ="1") Integer pageNum,  @RequestParam(defaultValue ="10") Integer pageSize ){
        PageInfo info = cmsSubjecService.pageinfo(keyword, pageNum, pageSize);
        return R.success("",info);
    }

    /*获取全部商品专题*/
    @GetMapping("/listAll")
    public R listAll(){
        List<CmsSubject> cmsSubjec =cmsSubjecService.listAll();
        return R.success("",cmsSubjec);
    }
}
